package com.bitbakery.plugin.lisp.lang.psi;

import com.bitbakery.plugin.lisp.lang.LispElementVisitor;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.NotNull;

public class CLArgumentList extends CLElement {
    private static final TokenSet ARGUMENT_FILTER = TokenSet.create(CLElementTypes.ARGUMENT);

    public CLArgumentList(final ASTNode node) {
        super(node);
    }

    public CLArgument[] getArguments() {
        final ASTNode[] nodes = getNode().getChildren(ARGUMENT_FILTER);
        final CLArgument[] args = new CLArgument[nodes.length];
        for (int i = 0; i < nodes.length; i++) {
            args[i] = (CLArgument) nodes[i].getPsi();
        }
        return args;
    }

    public void accept(@NotNull PsiElementVisitor visitor) {
        if (visitor instanceof LispElementVisitor) {
            ((LispElementVisitor) visitor).visitCommonLispArgumentList(this);
        } else {
            visitor.visitElement(this);
        }
    }

    public String toString() {
        return "CLArgumentList";
    }
}
